package org.scboy.common.dynamic.node.entityNode;

import java.util.List;

import org.scboy.common.annotation.ScriptNode;
import org.scboy.common.dynamic.node.BaseNode;
import org.scboy.utils.entitys.coobi.Model;

import cn.hutool.json.JSONObject;


@ScriptNode("LIST_CREATE")
public class ListNode extends BaseNode{

	@Override
	public void create(JSONObject object) {
		
	}

	@Override
	public Object run() {
		/**
		 * 测试日志
		 */
		if(this.script.isTest()) {
			this.script.appendMsg("----->开始执行："+getNodeName()+" 节点ID："+this.getId());
		}
		
		List<Model> listData=getSourceListData("list", false,Model.class);
		
		
		//合并追加
		List<Model> mergeList=getSourceDatas("params", false, Model.class);
		for (Model mergeData : mergeList) {
			listData.add(mergeData);
		}	
		
		/**
		 * 流出节点
		 */
		BaseNode runTo = getRunTo("to");
		
		this.setData("datas", listData);
		this.setData("size", listData.size());
		/**
		 * 测试日志
		 */
		if(this.script.isTest()) {
			this.script.appendMsg("缓存数据：\r\n"+entityToString(this.getDataAll()));
			this.script.appendMsg("执行下个节点："+runTo.getNodeName()+" 节点ID："+runTo.getId());
		}
		return runTo.run();
	}
	
}
